﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Shop.Data;
using Shop.Resources;

namespace Shop.AllForms
{
    public partial class QueryType : Form
    {
        public QueryType()
        {
            InitializeComponent();
        }

        private void buttonClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void buttonSearch_Click(object sender, EventArgs e)
        {
            int typeNumber = comboBoxType.SelectedIndex;
            dGVProductsByType.DataSource = ShopData.GetProductsByType(typeNumber);
        }

        private void buttonExport_Click(object sender, EventArgs e)
        {
            if (dGVProductsByType.RowCount == 0)
            {
                MessageBox.Show("Няма открити продукти, които да експортвате");
                return;
            }
            else
            {
                dGVProductsByType.ExportToExcel();
            }   
        }
    }
}
